﻿@model IEnumerable<orienta.Helper.DependenciaInfo>
@{
    Layout = "~/Views/Shared/_LayoutPopUpTree.cshtml";
    ViewBag.Title = "Index";
    var id = 0;
}
<script src="@Url.Content("~/js/midis.js")" type="text/javascript"></script>
<form id="form_lupita">
<table width="80%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="right">
            @Html.DropDownList("nIdeDepRegion", (IEnumerable<SelectListItem>)ViewBag.DepRegion, "--Seleccione Región--", new { onchange = "javascript:document.forms[0].submit();" })
            <input type="button" name="buscar" class="boton" style="width:75px;"  value="Seleccionar" onclick="javascript:botonSeleccionarMultiple();"  />
        </td>
    </tr>
</table>
<script language="javascript" type="text/javascript">
    d = new dTree('d');
    d.add(0, -1, 'Dependencias', '', 'Dependencias', '', '..images/trees/base.gif', '../images/trees/base.gif'); 
@foreach (var item in Model)
{
    id = id + 1;
    decimal? padre = @item.IdDepPadre;
    if (padre == null)
    {
        padre = 0;
    }
    if (@item.Seleccionado == 1)
    {
        @:d.add(@item.IdDep,@padre, '@item.DescDep <@String.Format("{0:0000}", item.IdDep)><input type=checkbox id="seleccionado" name="seleccionado[]"  value="@item.DescDep <@String.Format("{0:0000}", item.IdDep)-A>" size="1">', '', '@item.DescDep', '', '../images/trees/folder.gif', '../images/trees/folderopen.gif');
    }
    else
    { 
        @:d.add(@item.IdDep,@padre, '@item.DescDep <@String.Format("{0:0000}", item.IdDep)>', '', '@item.DescDep', '', '../images/trees/folder.gif', '../images/trees/folderopen.gif');
    }

}
    document.write(d);
    d.openTo(1, true);
    d.s(0); 
</script>
</form>
